+function($){
  viewinit();
  function viewinit(){
    $.get('/shop/getallshopselect', function(data) {
      var json = JSON.parse(data);
      var $shop = $('.shopid');
      for (var i = 0; i < json.length; i++) {
        if(json[i].shopid!=0){
          $shop.append('<option value="'+json[i].shopid+'">'+json[i].shopname+'</option>')
        }
      }
    });
    $.get('/brand/getallbrandselect', function(data) {
      var json = JSON.parse(data);
      var $brand = $('.bid');
      for (var i = 0; i < json.length; i++) {
        $brand.append('<option value="'+json[i].bid+'">'+json[i].bname+'</option>')
      }
    });
    $.get('/employee/getallemployeeselect', function(data) {
      var json = JSON.parse(data);
      var $emid = $('.emid');
      for (var i = 0; i < json.length; i++) {
        $emid.append('<option value="'+json[i].emid+'">'+json[i].emname+'</option>')
      }
    });
  }
  $('body').on('click', '#t1-summaryadd', function(event) {
		  var flag = true;
      $('input:not([type=button],:hidden),#t1-bid,#t1-emid').each(function(index, el) {
        if($(this).val()==''){
          $(this).css('border', '3px solid #f77');
					flag = false;
          alert('请将信息补充完整');
					return false;
        }
        $(this).attr('style', ' ');
      });
			if(flag == false){
				return false;
			}
      var postdata = {
  				shopid: $('#t1-shopid').val(),
  				bid: $('#t1-bid').val(),
  				inshop: $('#t1-inshop').val(),
  				content: $('#t1-content').val(),
  				outday: $('#t1-outday').val(),
  				seeboss: $('#t1-seeboss').val(),
  				getboss: $('#t1-getboss').val(),
  				tecount: $('#t1-tecount').val(),
  				outcount: $('#t1-outcount').val(),
  				skcount: $('#t1-skcount').val(),
  				joinv: $('#t1-joinv').val(),
  				sellcar: $('#t1-sellcar').val(),
  				meet: $('#t1-meet').val(),
          pass: $('#t1-pass').val()
      }
			$.post('/summary/summaryadd', postdata, function(data) {
        // console.log(data);
				if (data != 'false') {
					alert('添加成功');
				} else {
					alert('添加失败');
				}
			});
  });
  $('body').on('click', '#t2-summaryadd', function(event) {
		  var flag = true;
      $('input:not([type=button],:hidden),#t2-bid,#t2-emid').each(function(index, el) {
        if($(this).val()==''){
          $(this).css('border', '3px solid #f77');
					flag = false;
          alert('请将信息补充完整');
					return false;
        }
        $(this).attr('style', ' ');
      });
			if(flag == false){
				return false;
			}
      var postdata = {
        bid:$('#t2-bid').val(),
        content:$('#t2-content').val(),
        inshop:$('#t2-inshop').val(),
        outday:$('#t2-outday').val(),
        seeboss:$('#t2-seeboss').val(),
        getboss:$('#t2-getboss').val(),
        tecount:$('#t2-tecount').val(),
        skcount:$('#t2-skcount').val(),
        outcount:$('#t2-outcount').val(),
        singledo:$('#t2-singledo').val(),
        singlefuck:$('#t2-singlefuck').val(),
        joinv:$('#t2-joinv').val(),
        sellcar:$('#t2-sellcar').val(),
        meet:$('#t2-meet').val(),
        pass:$('#t2-pass').val()
      };
      $.post('/summary/summaryadd_t2', postdata, function(data) {
				if (data != 'false') {
					alert('添加成功');
				} else {
					alert('添加失败');
				}
      });
  });
  $('body').on('click', '#t3-summaryadd', function(event) {
		  var flag = true;
      $('input:not([type=button],:hidden),#t3-emid').each(function(index, el) {
        if($(this).val()==''){
          $(this).css('border', '3px solid #f77');
					flag = false;
          alert('请将信息补充完整');
					return false;
        }
        $(this).attr('style', ' ');
      });
			if(flag == false){
				return false;
			}
      var postdata = {
        content:$('#t3-content').val(),
        zone:$('#t3-zone').val(),
        outday:$('#t3-outday').val(),
        runshop:$('#t3-runshop').val(),
        meetcount:$('#t3-meetcount').val(),
        shopinfocount:$('#t3-shopinfocount').val(),
        bfshop:$('#t3-bfshop').val(),
        ysshop:$('#t3-ysshop').val(),
        ysgz:$('#t3-ysgz').val(),
        czshop:$('#t3-czshop').val(),
        czyj:$('#t3-czyj').val(),
        shopinfo:$('#t3-shopinfo').val(),
        newboss:$('#t3-newboss').val()
      };
      $.post('/summary/summaryadd_t3', postdata, function(data) {
				if (data != 'false') {
					alert('添加成功');
				} else {
					alert('添加失败');
				}
      });
  });
}(jQuery);
